<div class="row row-cards row-deck">
  <div class="col-2">
    <div class="card">
      <div class="card-body">
        <div class="form-group">
          <label class="form-label">商品处理</label>
          <div class="form-control-plaintext">
            <div><%= link_to "全部", shop_spus_path %></div>
            <div><%= link_to "货架", shop_spus_path(published: true, state: :onsale) %></div>
            <div><%= link_to "仓库", shop_spus_path(published: true, state: :onsale) %></div>
            <div><%= link_to "回收站", shop_spus_path(state: :ontrash) %></div>
          </div>
        </div>
        <div class="form-group">
          <label class="form-label">库存状态</label>
          <div class="form-control-plaintext">
            <div><%= link_to "全部", shop_spus_path %></div>
            <div><%= link_to "售完", shop_spus_path(check_stock: "zero") %></div>
            <div><%= link_to "紧张", shop_spus_path(check_stock: "below") %></div>
            <div><%= link_to "正常", shop_spus_path(check_stock: "normal") %></div>
            <div><%= link_to "富余", shop_spus_path(check_stock: "hyper") %></div>
          </div>
        </div>
        <div class="form-group">
          <label class="form-label">商品分类</label>
          <%= shop_categories_tree_in_index %>
        </div>
      </div>
    </div>
  </div>
  <div class="col-10">
    <div class="card">
      <table class="table table-hover table-outline table-vcenter text-nowrap card-table">
        <thead>
          <tr>
            <th>商品封面</th>
            <th>商品名字</th>
            <th>所属分类</th>
            <th>销售量</th>
            <th>是否上架</th>
            <th>拥有属性</th>
            <th>图片管理</th>
            <th>详情管理</th>
            <th>参数设置</th>
            <th class="text-center"><i class="icon-settings"></i></th>
          </tr>
        </thead>
        <tbody>
          <% @spus.each do |spu| %>
          <tr>
            <td class="text-center">
              <div class="avatar d-block" style="background-image: url(<%= spu.avatar.url %>)">
                <span class="avatar-status bg-green"></span>
              </div>
            </td>
            <td>
              <div><%= spu.name %></div>
              <div class="small text-muted">
                <%= formattime(spu.created_at, unit: "day") %>
              </div>
            </td>
            <td>
              <div><%= spu.shop_category.name %></div>
            </td>
            <td>
              <div><%= spu.sales_volume %></div>
            </td>
            <td>
              <div><%= spu.published ? '上架' : '下架' %></div>
            </td>
            <td>
              <div><%= link_to "属性管理", shop_spu_skus_path(spu) %></div>
            </td>
            <td>
              <div><%= link_to "图片管理", shop_spu_spu_images_path(spu) %></div>
            </td>
            <td>
              <div><%= link_to "详情管理", shop_spu_spu_details_path(spu) %></div>
            </td>
            <td>
              <div><%= link_to "参数管理", shop_spu_spu_parameters_path(spu) %></div>
            </td>
            <td class="text-center">
              <div class="item-action dropdown">
                <a href="javascript:void(0)" data-toggle="dropdown" class="icon"><i class="fe fe-more-vertical"></i></a>
                <div class="dropdown-menu dropdown-menu-right">
                  <a href="<%= shop_spu_path(spu) %>" class="dropdown-item"><i class="dropdown-icon fe fe-tag"></i> 查看详情 </a>
                  <a href="<%= orders_shop_spu_path(spu) %>" class="dropdown-item"><i class="dropdown-icon fe fe-tag"></i> 销售明细 </a>
                  <a href="<%= shop_spu_spu_coupons_path(spu) %>" class="dropdown-item"><i class="dropdown-icon fe fe-tag"></i> 绑定优惠券 </a>
                  <a href="<%= edit_shop_spu_path(spu) %>" class="dropdown-item"><i class="dropdown-icon fe fe-tag"></i> 修改 </a>
                  <% if spu.onsale? %>
                    <%= link_to published_shop_spu_path(spu), method: :post, class: 'dropdown-item' do %>
                      <i class="dropdown-icon fe fe-edit-2"></i> <%= spu.published ? "下架" : "上架" %> 
                    <% end %>
                  <% end %>
                  <%= link_to trash_shop_spu_path(spu), method: :post, class: 'dropdown-item' do %>
                    <i class="dropdown-icon fe fe-edit-2"></i> 移入回收站 
                  <% end %>
                  <% if spu.pending? || spu.disagree? %>
                    <%= link_to check_shop_spu_path(spu), method: :post, class: 'dropdown-item' do %>
                      <i class="dropdown-icon fe fe-edit-2"></i> 提交审核 
                    <% end %>
                  <% end %>
                  <% if spu.ontrash? %>
                    <%= link_to shop_spu_path(spu), method: :delete, class: 'dropdown-item' do %>
                      <i class="dropdown-icon fe fe-edit-2"></i> 删除 
                    <% end %>
                  <% end %>
                </div>
              </div>
            </td>
          </tr>
          <% end %>
        </tbody>
      </table>
      <div class="card-footer">
        <%= paginate @spus %>
      </div>
    </div>
  </div>
</div>